Skip to content

dialect: add slayer emit-only target - #1

Draft
yranchere wants to merge 1 commit into
mainfrom
slayer-dialect
Draft

dialect: add slayer emit-only target#1
yranchere wants to merge 1 commit into
mainfrom
slayer-dialect

Conversation

@yranchere

Copy link
Copy Markdown
Collaborator

What

Adds a slayer target dialect to semglot: any supported source (dbt, ossie) now transpiles into ready-to-import SLayer models — one SlayerModel v8 YAML per table, the exact shape slayer models create reads.

Mapping highlights

SLayer chooses aggregations at query time, so the IR maps with unusually high fidelity:

  • IR measures → named col:agg formulas (order_net_booked:sum)
  • Derived metrics → SLayer's formula DSL (net_revenue / orders, bare refs to saved measures)
  • Filtered aggregates → hidden columns carrying SLayer's aggregation-time filter:
  • dbt cumulative metrics → cumsum(...)
  • Query-typed table sources → sql: (query-backed model), a slot most targets lack
  • Synonyms → meta.synonyms (structured), enums fold into descriptions

Degrades (loud, per the loss policy)

  • Role-playing dimensions: SLayer allows one join per target model; first FK wins, rest → NOTES.md
  • Measure names colliding with a column (columns/measures share one namespace) or shadowing a transform name → renamed _measure with a note
  • Per-metric grains, slice-by restrictions, bounded windows, conversion metrics → NOTES.md

Verification

  • Full suite green: gofmt / go vet / go build / go test, unit tests + ecommerce goldens wired into the integration suite
  • Every emitted golden validates against SLayer's own SlayerModel.model_validate and its parse_formula (with the model's measure library) — this caught the shared-namespace and one-join-per-target constraints during development

Notes for reviewers

  • Emitter-only by design (CONTRIBUTING suggests emitter-first PRs); a Parser for slayer→IR would be the follow-up making it bidirectional
  • Internal review here first; once we're happy I'll open it upstream against benchouse/semglot

🤖 Generated with Claude Code

Emit one SLayer model YAML per table (SlayerModel schema v8, the shape
`slayer models create` reads; github.com/MotleyAI/slayer). SLayer picks
aggregations at query time, so the IR maps directly: measures become
named `col:agg` formulas, derived metrics lower to SLayer's formula DSL,
filtered aggregates become hidden columns carrying SLayer's
aggregation-time `filter:`, unbounded cumulative windows emit as
`cumsum(...)`, and a query table source lands in `sql:` (a query-backed
model). Degrades loudly per the loss policy: role-playing dimensions
(SLayer allows one join per target model), measure names colliding with
a column (shared namespace) or shadowing a transform name, per-metric
grains and slice-by restrictions, bounded windows, and conversion
metrics all go to NOTES.md.

Every emitted ecommerce golden validates against SLayer's own
SlayerModel.model_validate and its formula parser.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 408aa056-d7d6-4cf8-972d-5ae676c3eef2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant